package com.utils;

import com.alibaba.excel.EasyExcel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.List;

@Component
public class ExcelUtil {

    @Value("${easyexcel.outtype}")
    private String easyexcelType;

    public void SimpleWrite(String easyexcelOut,String fileName, Class cla, String sheetName, List data){
        System.out.println(easyexcelOut);
        File backOut = new File(easyexcelOut);
        if(!backOut.exists())
            backOut.mkdirs();

        File file =new File(backOut,fileName+easyexcelType);
        EasyExcel.write(file,cla).sheet(sheetName).doWrite(data);

    }

}
